package com.twu.soloproject;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: thoughtworker
 * Date: 10/10/13
 * Time: 2:50 PM
 * To change this template use File | Settings | File Templates.
 */
public class Team {

    private Map<String, String> coaches;
    private String teamName;
    private Collection<Player> players;


    public Team(String teamName, Map<String, String> coaches) {
        this.teamName = teamName;
        this.coaches = coaches;
        this.players = new HashSet<Player>();
    }

    public String getCoachDetails() {
        String whatCoaches = "";
        for (String coach: coaches.keySet()) {
            whatCoaches += "Name: " + coach + ", Title: " + coaches.get(coach) + "\n";
        }
        return whatCoaches;

    }

    public String getTeamName() {
        return teamName;
    }

    public void addPlayer(Player player) {
        players.add(player);
    }

    public String getTeamDetails() {
        String listingInfo = "Players:\n";
        for (Player player: players) {
            listingInfo += player.displayInfo() + "\n";
        }

        return listingInfo + "\nCoaches:\n" + getCoachDetails();

    }

    public boolean isPlayerInTeam(Player player) {
        return players.contains(player);

    }
}
